<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/fuman/js/oversea.js"></script>
<title>{{$web_title}}</title>
<body class="withvernav">
<style type="text/css">
.stdtable tbody tr td{padding:3px 5px;}
.nothave{background:red}
.color0{color:red;}
.waring{background:#FF9900};
</style>
<div class="bodywrapper">
    {{include file='/public/leftmenu.tpl'}}
    <div class="centercontent tables">
        <div class="pageheader notab">
            <h1 class="pagetitle" id="pagetitle">{{$web_title}}</h1>
            <span class="pagedesc"></span>
        </div>
        <!--pageheader-->
        <form method="post" action="/CheckExpressPrice/ajaxbutton" target="_blank" name="deliverForm" id="deliverForm">
            <div class="page" style="height:28px;padding:2px 20px;">
                <span style="float:left;border:0px;background:none;">
                 <a href="javascript:exportExl();">导出对帐及核算结果</a>
                </span>
               <span style="float:right;border:0px;background:none;"> &nbsp; <a href="javascript:history.back();">返回上页</a></span>
                <input type="hidden" value="outputCheckRecive" name="op" id="op">
                <input type="hidden" value="" name="filename" id="filename">
                <input type="hidden" value="" name="htmldata" id="htmldata">
            </div>
       </form>

        <div id="contentwrapper" class="contentwrapper"><table cellpadding="0" cellspacing="0" border="0" class="stdtable">
            	<thead>
                <tr bgcolor="#EEEEEE">
                   <th class="head1">EXCEL&nbsp;行号</th>
                    <th class="head1">订单编号</th>
                    <th class="head1">完成日期</th>
                    <th class="head1">商品SKU</th>
                    <th class="head1">均码信息</th>
                  <th class="head1">工厂出货数量</th>
                    <th class="head1">复漫收货数量</th>
                    <th class="head1">清算日期</th>
                    <th class="head1">出厂价/关联价</th>
                    <th class="head1">是否批量</th>
                </tr>
                </thead>
                {{foreach from=$chargeslist item=li key=key}}
                    <tr>
                      <td>{{$li.id}}</td>
                      <td class="{{$li.checkstatus}}"><a href="/factory/scanorder?other={{$li.order_number}}" target="_blank">{{$li.order_number}}</a></td>
                        <td>{{$li.made_date}}</td>
                        <td class="{{if $li.skuerror==1}}waring{{/if}}">
                           <a href="/product/productlist?other={{$li.sku}}&filtertype=skuc" target="_blank">{{$li.sku}}</a>                   </td>
                        <td class="{{if $li.styleerror==1}}waring{{/if}}"> {{$li.specifications}}  </td>
                        <td class="{{if $li.numbererror==1}}waring{{/if}}">{{$li.numbers}}</td>
                        <td>{{$li.goods_num}}</td>
                        <td>{{$li.recive_date}}{{$li.check_id}}</td>
                        <td>{{$li.costprice}}</td>
                        <td>{{if $li.data_type==1}}批量{{else}}单件定制{{/if}}</td>
          </tr>
                {{/foreach}}
               
                <tr >
                  <td colspan="10" align="center" id="updatetd">
                  <form method="post" action="/factory/ajaxbutton?op=sendGoodsCheckSave" id="updateform" target="_blank">
                  <input type="hidden"  name="check_data_json" id="check_data_json" value='{{$check_data_json}}'>
                  <input type="hidden" name="check_error_data_json" id="check_error_data_json" value='{{$check_error_data_json}}'>
                  <input type="hidden" value="{{$total_num}}" name="total_num" id="total_num" >
                  <input type="hidden" value="{{$total_price}}" name="total_price" id="total_price" >
                  <input type="hidden" value="{{$check_day}}" name="check_day" id="check_day" >
                  <input type="hidden" value="{{$factory_num}}" name="factory_num" id="factory_num" >
                  <input type="hidden" value="{{$factory}}" name="factory" id="factory" >
                  <input type="hidden" value="{{$factory_price}}" name="factory_price" id="factory_price" >
                  <button id="btn2" type="button" onClick="return updateRealExpPrice()" class="submit radius2">保存出货对帐结果</button>
                  </form>                  </td>
          </tr>
            </table>
      </div>
            <br />
 <div class="outputtag" style="display:none;">
<table width="1062" height="140">
    <tr height="19">
      <td width="107" height="19" bgcolor="EEEEEE"><strong>单号</strong></td>
      <td width="75" height="19" bgcolor="EEEEEE"><strong>SKU</strong></td>
      <td width="177" height="19" bgcolor="EEEEEE"><strong>商品名称</strong></td>
      <td width="96" height="19" bgcolor="EEEEEE"><strong>版型</strong></td>
      <td width="72" height="19" bgcolor="EEEEEE"><strong>性别</strong></td>
      <td width="72" height="19" bgcolor="EEEEEE"><strong>尺码</strong></td>
      <td width="90" height="19" bgcolor="EEEEEE"><strong>数量</strong></td>
      <td width="90" bgcolor="EEEEEE"><strong>复漫收货数</strong></td>
      <td width="110" height="19" bgcolor="EEEEEE"><strong>关联价</strong></td>
      <td width="109" height="19" bgcolor="EEEEEE"><strong>出货关联总计</strong></td>
    </tr>
{{foreach from=$chargeslist item=li key=key}}
	{{if $li.data_type==1}}
    <tr height="19">
      <td height="19" width="107">{{$li.order_number}}</td>
      <td height="19" width="75">{{$li.sku}}</td>
      <td height="19" width="177">{{$li.goods_name}}</td>
      <td height="19" width="96">{{$li.style}}</td>
      <td height="19" width="72">{{$li.sex}}</td>
      <td height="19" width="72">{{$li.size}}</td>
      <td height="19" width="90">{{$li.numbers}}</td>
      <td height="19" width="90">{{$li.goods_num}}</td>
      <td height="19" width="110">{{$li.costprice}}</td>
      <td height="19" width="109">{{$li.numbers*$li.costprice}}</td>
    </tr>
   {{/if}}
{{/foreach}}
    <tr height="19">
      <td height="19" width="107"></td>
      <td height="19" width="75"></td>
      <td height="19" width="177"></td>
      <td height="19" width="96"></td>
      <td height="19" width="72"></td>
      <td height="19" width="72"><strong>数量总计</strong></td>
      <td height="19" width="90"><strong>{{$totalinfo[2]}}</strong></td>
      <td width="90">{{$totalinfo[0]}}</td>
      <td height="19" width="110"><strong>关联价总计</strong></td>
      <td height="19" width="109"><strong>{{$totalinfo[6]}}</strong></td>
    </tr>
    <tr height="19">
      <td height="19"></td>
      <td height="19"></td>
      <td height="19"></td>
      <td height="19"></td>
      <td height="19"></td>
      <td height="19"></td>
      <td height="19">&nbsp;</td>
      <td>&nbsp;</td>
      <td height="19">&nbsp;</td>
      <td height="19">&nbsp;</td>
    </tr>
  </table>

    <table width="561" height="91">
      <col width="107" />
      <col width="75" />
      <col width="177" />
      <col width="96" />
      <col width="72" />
      <col width="72" />
      <tr height="19">
        <td width="107" height="19" bgcolor="EEEEEE"><strong>完成日期</strong></td>
        <td width="75" height="19" bgcolor="EEEEEE"><strong>生产方式</strong></td>
        <td width="177" height="19" bgcolor="EEEEEE"><strong>SKU</strong></td>
        <td width="96" height="19" bgcolor="EEEEEE"><strong>数量</strong></td>
        <td width="72" height="19" bgcolor="EEEEEE"><strong>出厂价</strong></td>
      </tr>
{{foreach from=$chargeslist item=li key=key}}
	{{if $li.data_type==2}}
      <tr height="19">
        <td height="19" width="107">{{$li.made_date|substr:0:16}}</td>
        <td height="19" width="75">{{$li.size}}</td>
        <td height="19" width="177">{{$li.sku}}</td>
        <td height="19" width="96">{{$li.numbers}}</td>
        <td height="19" width="72" class="color{{$li.costprice}}">{{$li.costprice}}</td>
      </tr>
	{{/if}}
{{/foreach}}
      <tr height="19">
        <td height="19" width="107">总计：</td>
        <td height="19" width="75">&nbsp;</td>
        <td height="19" width="177">&nbsp;</td>
        <td height="19" width="96"><strong>{{$totalinfo[5]}}</strong></td>
        <td height="19" width="72"><strong>{{$totalinfo[4]}}</strong></td>
      </tr>
    </table>
 </div>
            <br />
        </div>
    </div>
<script language="javascript">
	function exportExl(){
		$(".outputtag").table2excel({
			// 不被导出的表格行的CSS class类
			exclude: ".noExl",
			// 导出的Excel文档的名称，（没看到作用）
			name: "reportlist",
			filename: "{{$check_day}}号出货对帐与核算结果_" + new Date().toISOString().substr(0,10),
			fileext: ".xls",
			exclude_img: true,
			exclude_links: false,
			exclude_inputs: false
		});
	}
	function outputexl(infotype){
		var filename=$("#pagetitle").html();
		var htmldata=$("#alldata").val();
		
		if(infotype=='exist'){
			$("#filename").val(filename+"_正常");
			htmldata=$("#existdata").val();
		}else if(infotype=='notexist'){//
			$("#filename").val(filename+"_异常");
			htmldata=$("#notexistdata").val();
		}else{//all
			$("#filename").val(filename);	
		}
		$("#htmldata").val(htmldata);
		$("#deliverForm").submit();
		return;
	}
	
	function  updateRealExpPrice(){
		var point=$("#point").val();
		if(!confirm('确定保存收货对帐数据吗？')){
			return;
		}
		$("#btn2").attr("disabled",true);
		$("#updateform").submit();
	}

//table2excel.js
;(function ( $, window, document, undefined ) {
    var pluginName = "table2excel",

    defaults = {
        exclude: ".noExl",
                name: "Table2Excel"
    };

    // The actual plugin constructor
    function Plugin ( element, options ) {
            this.element = element;
            // jQuery has an extend method which merges the contents of two or
            // more objects, storing the result in the first object. The first object
            // is generally empty as we don't want to alter the default options for
            // future instances of the plugin
            //
            this.settings = $.extend( {}, defaults, options );
            this._defaults = defaults;
            this._name = pluginName;
            this.init();
    }

    Plugin.prototype = {
        init: function () {
            var e = this;

            e.template = {
                head: "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns=\"http://www.w3.org/TR/REC-html40\"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets>",
                sheet: {
                    head: "<x:ExcelWorksheet><x:Name>",
                    tail: "</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>"
                },
                mid: "</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>",
                table: {
                    head: "<table border=1>",
                    tail: "</table>"
                },
                foot: "</body></html>"
            };

            e.tableRows = [];

            // get contents of table except for exclude
            $(e.element).each( function(i,o) {
                var tempRows = "";
                $(o).find("tr").not(e.settings.exclude).each(function (i,o) {
                    tempRows += "<tr>" + $(o).html() + "</tr>";
                });
                e.tableRows.push(tempRows);
            });

            e.tableToExcel(e.tableRows, e.settings.name);
        },

        tableToExcel: function (table, name) {
            var e = this, fullTemplate="", i, link, a;

            e.uri = "data:application/vnd.ms-excel;base64,";
            e.base64 = function (s) {
                return window.btoa(unescape(encodeURIComponent(s)));
            };
            e.format = function (s, c) {
                return s.replace(/{(\w+)}/g, function (m, p) {
                    return c[p];
                });
            };
            e.ctx = {
                worksheet: name || "Worksheet",
                table: table
            };

            fullTemplate= e.template.head;

            if ( $.isArray(table) ) {
                for (i in table) {
                    //fullTemplate += e.template.sheet.head + "{worksheet" + i + "}" + e.template.sheet.tail;
                    fullTemplate += e.template.sheet.head + "Table" + i + "" + e.template.sheet.tail;
                }
            }

            fullTemplate += e.template.mid;

            if ( $.isArray(table) ) {
                for (i in table) {
                    fullTemplate += e.template.table.head + "{table" + i + "}" + e.template.table.tail;
                }
            }

            fullTemplate += e.template.foot;

            for (i in table) {
                e.ctx["table" + i] = table[i];
            }
            delete e.ctx.table;

            if (typeof msie !== "undefined" && msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))      // If Internet Explorer
            {
                if (typeof Blob !== "undefined") {
                    //use blobs if we can
                    fullTemplate = [fullTemplate];
                    //convert to array
                    var blob1 = new Blob(fullTemplate, { type: "text/html" });
                    window.navigator.msSaveBlob(blob1, getFileName(e.settings) );
                } else {
                    //otherwise use the iframe and save
                    //requires a blank iframe on page called txtArea1
                    txtArea1.document.open("text/html", "replace");
                    txtArea1.document.write(e.format(fullTemplate, e.ctx));
                    txtArea1.document.close();
                    txtArea1.focus();
                    sa = txtArea1.document.execCommand("SaveAs", true, getFileName(e.settings) );
                }

            } else {
                link = e.uri + e.base64(e.format(fullTemplate, e.ctx));
                a = document.createElement("a");
                a.download = getFileName(e.settings);
                a.href = link;

                document.body.appendChild(a);

                a.click();

                document.body.removeChild(a);
            }

            return true;
        }
    };

    function getFileName(settings) {
        return ( settings.filename ? settings.filename : "table2excel") + ".xls";
    }

    $.fn[ pluginName ] = function ( options ) {
        var e = this;
            e.each(function() {
                if ( !$.data( e, "plugin_" + pluginName ) ) {
                    $.data( e, "plugin_" + pluginName, new Plugin( this, options ) );
                }
            });

        // chain jQuery functions
        return e;
    };

})( jQuery, window, document );
</script>
</body>
</html>